//
// Created by Semir on 2020/4/23.
//

#include <iostream>
#include <string>
#include <cstring>

using namespace std;

const int MAX_LEN = 2005;
int carry[MAX_LEN];
int n;
string a, b;

void swap(string *a, string *b) {
    string temp = *a;
    *a = *b;
    *b = temp;
}

int getTrueValue(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return c - 'A' + 10;
}

char getSystemChar(int value) {
    if (value < 10) {
        return value + '0';
    } else {
        return value - 10 + 'A';
    }
}

string calculateAddition(int n, string a, string b) {
    memset(carry, 0, sizeof(carry));
    if (a.length() > b.length()) {
        swap(a, b);
    }
    string concat(b.length() - a.length(), '0');
    a = '0' + concat + a;
    b = '0' + b;
    string res(a.length(), '0');
    for (int i = a.length() - 1; i > 0; i--) {
        int sum = getTrueValue(a[i]) + getTrueValue(b[i]) + carry[i];
        carry[i - 1] = sum / n;
        res[i] = getSystemChar(sum % n);
    }
    res[0] = getSystemChar(carry[0]);
    for (int i = 0; i < res.length(); i++) {
        if (res[i] != '0') {
            res = res.substr(i);
            break;
        }
    }
    return res;
}

int main() {
    cin >> n >> a >> b;
    cout << calculateAddition(n, a, b) << endl;
    return 0;
}